/**
 * Copyright 2013 Bhushan
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 */
package org.s4j.signals.core;

/**
 * Contains the details of a signal. Primarily contains the object that the signal corresponds to and the name of the
 * signal.
 * 
 * @author Bhushan
 * 
 */
public class SignalContainer implements Invocable {

    private String signalName;
    private Bridgeable object;

    @SuppressWarnings("rawtypes")
    private Class[] parameterTypes;

    public SignalContainer() {
    }

    @SuppressWarnings("rawtypes")
    public SignalContainer(final Bridgeable object, final String signalName, final Class[] types) {
        this.object = object;
        this.signalName = signalName;
        this.parameterTypes = types;
    }

    @Override
    public void accept(final InvocationVisitor visitor, final Object... parameters) {
        visitor.visit(this, parameters);
    }

    public Bridgeable getObject() {
        return object;
    }

    public void setObject(Bridgeable object) {
        this.object = object;
    }

    public String getSignalName() {
        return signalName;
    }

    public void setSignalName(String signalName) {
        this.signalName = signalName;
    }

    @SuppressWarnings("rawtypes")
    public Class[] getParameterTypes() {
        return parameterTypes;
    }

    @SuppressWarnings("rawtypes")
    public void setParameterTypes(Class[] parameterTypes) {
        this.parameterTypes = parameterTypes;
    }

    @Override
    public int hashCode() {
        return object.hashCode() | signalName.hashCode();
    }

    @Override
    public boolean equals(final Object obj) {
        if (obj == null)
            return false;
        if (obj instanceof SignalContainer) {
            // TODO: null checks need to be added
            return this.object.equals(((SignalContainer) obj).object)
                    && this.signalName.equals(((SignalContainer) obj).signalName);
        }
        return false;
    }

}
